home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / homefix.zip / HOMING.QC < prev    next >
Text File  |  1996-11-11  |  4KB  |  174 lines

  1. //====================================================================
  2. //
  3. // Selected Homing by Lee Murdock lng@isat.com
  4. // Alternate W_FireRocket by Vhold@netwizards.net
  5. //
  6. //====================================================================
  7. // Aside from this new file, the following are the modifications
  8. // done to id's original source files:
  9. //--------------------------------------------------------------------
  10. // File: Progs.src
  11. // Location: before the "weapons.qc" line
  12. // Added: homing.qc
  13. //--------------------------------------------------------------------
  14. // File: Weapons.qc
  15. // Procedure: ImpulseCommands
  16. // Location: in the function
  17. // Added: 
  18. //    if (self.impulse == 40)
  19. //        ActivateHoming ();
  20. //    if (self.impulse == 41)
  21. //        DeativateHoming ();
  22. // Note: Use an alias to bind these two impulses to one Key.
  23. //--------------------------------------------------------------------
  24. // File: Defs.qc
  25. // Declaration group: player only fields
  26. // Location: after line ".float pain_finished;"
  27. // Added: .float homing;    
  28. //--------------------------------------------------------------------
  29. // File: Weapons.qc
  30. // Procedure: W_FireRocket
  31. // Location: after W_FireRocket
  32. /*
  33. ================
  34. W_FireHomingRocket
  35. ================
  36. */
  37. /*
  38. void()   HomeThink;
  39. entity() HomeFindTarget;
  40. float(entity targ) visible;
  41. float(entity targ) infront;
  42.  
  43. void() W_FireHomingRocket =
  44. {
  45.     local    entity missile, mpuff;
  46.     
  47.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  48.     
  49.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  50.  
  51.  
  52.     self.punchangle_x = -2;
  53.  
  54.     missile = spawn ();
  55.     missile.owner = self;
  56.     missile.movetype = MOVETYPE_FLYMISSILE;
  57.     missile.solid = SOLID_BBOX;
  58.         
  59. // set missile speed    
  60.  
  61.     makevectors (self.v_angle);
  62.     missile.velocity = aim(self, 1000);
  63.     missile.velocity = missile.velocity * 300;
  64.     missile.angles = vectoangles(missile.velocity);
  65.     missile.touch = T_MissileTouch;
  66.     missile.nextthink = time + 0.2;
  67.     missile.think = HomeThink;
  68.     missile.enemy = world;
  69.  
  70.     setmodel (missile, "progs/missile.mdl");
  71.     setsize (missile, '0 0 0', '0 0 0');        
  72.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  73. };
  74.  
  75. entity() HomeFindTarget = 
  76. {
  77.     local entity head, selected;
  78.     local float dist;
  79.     dist = 100000;
  80.     selected = world;
  81.     head = findradius(self.origin, 100000);
  82.     while(head)
  83.     {
  84.         if( (head.health > 1) && (head != self) && (head != self.owner) )
  85.         {
  86.             traceline(self.origin,head.origin,TRUE,self);
  87.             if ( (trace_fraction >= 1) && (vlen(head.origin - self.origin) < dist) )
  88.             {
  89.                 selected = head;
  90.                 dist = vlen(head.origin - self.origin);
  91.             }
  92.         }        
  93.         head = head.chain;
  94.     }
  95.     if (selected != world)
  96.     {
  97.         sprint (self.owner,"Homing->");
  98.         if (selected.classname == "player")
  99.         {
  100.             sprint (self.owner,selected.netname);
  101.             sprint (selected,self.owner.netname);
  102.             sprint (selected," has a bogey on you!\n");
  103.         }
  104.         else
  105.             sprint (self.owner,selected.classname);
  106.         sprint (self.owner,"\n");
  107.     }
  108.     return selected;
  109. };
  110.  
  111. void() HomeThink =
  112. {
  113.     local vector dir, vtemp;
  114.  
  115.     if ( !(self.enemy) || (self.enemy == world) || (self.enemy.health < 1) )
  116.         self.enemy = HomeFindTarget();
  117.  
  118.     if (self.enemy != world) // Arr.. don't be taken on da World!
  119.     {
  120.         vtemp = self.enemy.origin + '0 0 10';
  121.         dir = normalize(vtemp - self.origin);
  122.         self.velocity = dir * 250;
  123.         self.angles = vectoangles(self.velocity);
  124.     }
  125.  
  126.     self.nextthink = time + 0.2;
  127.     self.think=HomeThink;
  128. };
  129. */
  130. // ---------------------------------------------------------------------
  131. // File: Weapons.qc
  132. // Procedure: W_Attack
  133. // Location: see below
  134. /*
  135.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  136.     {
  137.         player_rocket1();
  138.         CheckHomingRocket();    //replace W_FireRocket with this
  139.         self.attack_finished = time + 0.8;
  140.     }
  141.  
  142. */
  143. // ---------------------------------------------------------------------
  144. //BEGIN HOMING.qc
  145. void () W_FireHomingRocket;
  146. void () W_FireRocket;
  147. float HOMING_ON = 1;    //bit flag
  148. float HOMING_OFF = 2;    //bit flag
  149.  
  150. //Activate Homing Rockets
  151. void () ActivateHoming =
  152. {
  153.     if (deathmatch || coop)    //No more cheese!
  154.         return;
  155.     self.homing = HOMING_ON;
  156.     return;
  157. };
  158.  
  159. //Deactivate Homing Rockets
  160. void () DeactivateHoming =
  161. {
  162.     self.homing = HOMING_OFF;
  163.     return;
  164. };
  165.  
  166. //Check to see if Homing is activated
  167. void () CheckHomingRocket =
  168. {
  169.     if (self.homing == HOMING_ON)
  170.         W_FireHomingRocket ();
  171.     else if (self.homing == HOMING_OFF)
  172.         W_FireRocket ();
  173. };
  174.